home *** CD-ROM | disk | FTP | other *** search
/ Champak 141 / (Vol 141) Oct 17 2011.iso / Games / dragon-runner.swf / scripts / DragonChar.as < prev    next >
Encoding:
Text File  |  2011-10-17  |  15.0 KB  |  508 lines

  1. package
  2. {
  3.    import flash.display.MovieClip;
  4.    import flash.events.Event;
  5.    
  6.    public class DragonChar extends MovieClip
  7.    {
  8.        
  9.       
  10.       internal const DRAGONMAXFIRE:* = 4;
  11.       
  12.       private var ┬º\x01\x01\n\x03┬º:int = 10000;
  13.       
  14.       private var ┬º\x01\x01\n\x04┬º:Array;
  15.       
  16.       internal const DOC_HEIGHT:* = 400;
  17.       
  18.       private var theKnight:* = null;
  19.       
  20.       private var ┬º\x01\x01\n\x07┬º:int = 0;
  21.       
  22.       private var ┬º\x01\x01\n\b┬º:int = 0;
  23.       
  24.       internal const DRAGONATTACKBLAST:* = 1;
  25.       
  26.       internal const HEALTHDAMAGE:* = 50;
  27.       
  28.       internal const DOC_LEFT:* = 0;
  29.       
  30.       internal const DRAGONATTACKFIRE:* = 3;
  31.       
  32.       internal const FIREINITX:* = 650;
  33.       
  34.       internal const FIREINITY:* = 95;
  35.       
  36.       private var ┬º\x01\x01\x02\t┬º:* = null;
  37.       
  38.       internal const DRAGONATTACKUPPER:* = 2;
  39.       
  40.       private var ┬º\x01\x01\n\r┬º:Number;
  41.       
  42.       private var ┬º\x01\x01\n\x0e┬º:Number;
  43.       
  44.       internal const ARMORDAMAGE:* = 30;
  45.       
  46.       public var burstfire:MovieClip;
  47.       
  48.       private var ┬º\x01\x01\x06\r┬º:* = null;
  49.       
  50.       public var ┬º\x01\x01\n\x10┬º:* = null;
  51.       
  52.       public var ┬º\x01\x01\x0b\x01┬º:* = null;
  53.       
  54.       public var ┬º\x01\x01\x0b\x02┬º:* = null;
  55.       
  56.       internal const DOC_TOP:* = 0;
  57.       
  58.       internal const DOC_QUARTI:* = 160;
  59.       
  60.       internal const DRAGONATTACKBITE:* = 4;
  61.       
  62.       internal const DRAGONINITDELAY:* = 10000;
  63.       
  64.       private var ┬º\x01\x01\x0b\x03┬º:int = 0;
  65.       
  66.       private var ┬º\x01\x01\x0b\x04┬º:int = 0;
  67.       
  68.       internal const DRAGONATTACKSPACE:* = 100;
  69.       
  70.       public var ┬º\x01\x01\x0b\x05┬º:* = null;
  71.       
  72.       private var ┬º\x01\x01\x04\x0e┬º:Boolean;
  73.       
  74.       internal const DOC_WIDTH:* = 640;
  75.       
  76.       private var ┬º\x01\x01\x0b\x06┬º:int = 0;
  77.       
  78.       internal const DRAGONHIDE:* = 0;
  79.       
  80.       internal const DRAGONDELAYDECR:* = 50;
  81.       
  82.       private var ┬º\x01\x01\x0b\x07┬º:int = 0;
  83.       
  84.       internal const DOC_MIDH:* = 320;
  85.       
  86.       internal const DOC_QUARTII:* = DOC_MIDH + DOC_QUARTI;
  87.       
  88.       internal const DOC_MIDV:* = 200;
  89.       
  90.       public function DragonChar()
  91.       {
  92.          ┬º\x01\x01\n\x03┬º = DRAGONINITDELAY;
  93.          ┬º\x01\x01\x0b\x04┬º = 0;
  94.          ┬º\x01\x01\x0b\x06┬º = 0;
  95.          ┬º\x01\x01\x02\t┬º = null;
  96.          ┬º\x01\x01\x06\r┬º = null;
  97.          theKnight = null;
  98.          ┬º\x01\x01\x0b\x07┬º = 0;
  99.          ┬º\x01\x01\n\b┬º = 0;
  100.          ┬º\x01\x01\x0b\x03┬º = 0;
  101.          ┬º\x01\x01\n\x04┬º = new Array();
  102.          ┬º\x01\x01\n\x10┬º = null;
  103.          ┬º\x01\x01\x0b\x01┬º = null;
  104.          ┬º\x01\x01\x0b\x05┬º = null;
  105.          ┬º\x01\x01\x0b\x02┬º = null;
  106.          ┬º\x01\x01\n\x07┬º = 0;
  107.          super();
  108.       }
  109.       
  110.       public function ┬º\x01\x01\n\x02┬º(param1:*) : *
  111.       {
  112.          ┬º\x01\x01\x0b\x03┬º = param1;
  113.       }
  114.       
  115.       public function GetDragonStatus() : int
  116.       {
  117.          return ┬º\x01\x01\x0b\x07┬º;
  118.       }
  119.       
  120.       private function ┬º\x01\x01\n\x05┬º() : Boolean
  121.       {
  122.          if(┬º\x01\x01\x0b\x06┬º <= 0)
  123.          {
  124.             ┬º\x01\x01\x0b\x06┬º = Math.round((Math.random() * ┬º\x01\x01\n\x03┬º + ┬º\x01\x01\n\x03┬º) / 42);
  125.             ┬º\x01\x01\n\x03┬º -= DRAGONDELAYDECR;
  126.             return true;
  127.          }
  128.          --┬º\x01\x01\x0b\x06┬º;
  129.          return false;
  130.       }
  131.       
  132.       public function ┬º\x01\x01\n\x06┬º(param1:int) : *
  133.       {
  134.          if(theKnight.Health > 0)
  135.          {
  136.             switch(param1)
  137.             {
  138.                case DRAGONHIDE:
  139.                   if(┬º\x01\x01\x0b\x07┬º != DRAGONATTACKBITE)
  140.                   {
  141.                      ┬º\x01\x01\x0b\x07┬º = DRAGONHIDE;
  142.                      ┬º\x01\x01\n\b┬º = ┬º\x01\x01\x0b\x07┬º;
  143.                      gotoAndStop(1);
  144.                   }
  145.                   else
  146.                   {
  147.                      ┬º\x01\x01\x0b\x07┬º = DRAGONHIDE;
  148.                      ┬º\x01\x01\n\b┬º = ┬º\x01\x01\x0b\x07┬º;
  149.                      gotoAndPlay("bitehide");
  150.                   }
  151.                   break;
  152.                case DRAGONATTACKBLAST:
  153.                   ┬º\x01\x01\x0b\x07┬º = DRAGONATTACKBLAST;
  154.                   gotoAndPlay("blast");
  155.                   break;
  156.                case DRAGONATTACKUPPER:
  157.                   ┬º\x01\x01\x0b\x07┬º = DRAGONATTACKUPPER;
  158.                   gotoAndPlay("burst");
  159.                   break;
  160.                case DRAGONATTACKFIRE:
  161.                   ┬º\x01\x01\x0b\x07┬º = DRAGONATTACKFIRE;
  162.                   gotoAndPlay("fire");
  163.                   break;
  164.                case DRAGONATTACKBITE:
  165.                   if(┬º\x01\x01\x0b\x07┬º != DRAGONATTACKBITE)
  166.                   {
  167.                      ┬º\x01\x01\x0b\x07┬º = DRAGONATTACKBITE;
  168.                      gotoAndPlay("bite");
  169.                   }
  170.                   else
  171.                   {
  172.                      ┬º\x01\x01\x0b\x07┬º = DRAGONATTACKBITE;
  173.                      gotoAndPlay("biting");
  174.                   }
  175.                   break;
  176.                default:
  177.                   ┬º\x01\x01\x0b\x07┬º = DRAGONHIDE;
  178.                   gotoAndStop(1);
  179.             }
  180.          }
  181.       }
  182.       
  183.       public function GetArmorDamage() : int
  184.       {
  185.          if(this.currentLabel == "biting")
  186.          {
  187.             return ARMORDAMAGE;
  188.          }
  189.          if(this.currentLabel == "blasting")
  190.          {
  191.             return ARMORDAMAGE * 0.5;
  192.          }
  193.          return 0;
  194.       }
  195.       
  196.       private function ┬º\x01\x01\n\t┬º(param1:Event) : *
  197.       {
  198.          if(theKnight.Health > 0)
  199.          {
  200.             switch(┬º\x01\x01\x0b\x07┬º)
  201.             {
  202.                case DRAGONHIDE:
  203.                   if(theKnight.x <= DOC_QUARTI && Math.random() > 0.9)
  204.                   {
  205.                      ┬º\x01\x01\n\x06┬º(DRAGONATTACKBITE);
  206.                   }
  207.                   if(┬º\x01\x01\n\x05┬º())
  208.                   {
  209.                      ┬º\x01\x01\n\x06┬º(┬º\x01\x01\n\n┬º());
  210.                      ┬º\x01\x01\n\x03┬º -= 100;
  211.                   }
  212.             }
  213.             if(this.currentLabel == "hide")
  214.             {
  215.                ┬º\x01\x01\n\b┬º = 0;
  216.                ┬º\x01\x01\x0b\x07┬º = DRAGONHIDE;
  217.             }
  218.             else if(this.currentLabel == "stopburst")
  219.             {
  220.                ┬º\x01\x01\n\b┬º = 0;
  221.                if(┬º\x01\x01\x0b\x03┬º > 1)
  222.                {
  223.                   this.x += 50;
  224.                   gotoAndPlay("burst");
  225.                   --┬º\x01\x01\x0b\x03┬º;
  226.                }
  227.                else
  228.                {
  229.                   this.x = ┬º\x01\x01\n\r┬º;
  230.                   gotoAndStop("hide");
  231.                }
  232.             }
  233.             else if(this.currentLabel == "firing1")
  234.             {
  235.                ┬º\x01\x01\x0b\b┬º(1);
  236.                play();
  237.             }
  238.             else if(this.currentLabel == "firing2")
  239.             {
  240.                if(┬º\x01\x01\x0b\x03┬º >= 2)
  241.                {
  242.                   ┬º\x01\x01\x0b\b┬º(2);
  243.                   play();
  244.                }
  245.                else
  246.                {
  247.                   gotoAndStop("firing1");
  248.                }
  249.             }
  250.             else if(this.currentLabel == "firing3")
  251.             {
  252.                if(┬º\x01\x01\x0b\x03┬º >= 3)
  253.                {
  254.                   ┬º\x01\x01\x0b\b┬º(3);
  255.                   play();
  256.                }
  257.                else
  258.                {
  259.                   gotoAndStop("firing2");
  260.                }
  261.             }
  262.             else if(this.currentLabel == "firing4")
  263.             {
  264.                if(┬º\x01\x01\x0b\x03┬º >= 4)
  265.                {
  266.                   ┬º\x01\x01\x0b\b┬º(4);
  267.                   play();
  268.                }
  269.                else
  270.                {
  271.                   gotoAndStop("firing3");
  272.                }
  273.             }
  274.             else if(this.currentLabel == "biting" || this.currentLabel == "bursting" || this.currentLabel == "blasting")
  275.             {
  276.                if(┬º\x01\x01\x0b\x07┬º != ┬º\x01\x01\n\b┬º)
  277.                {
  278.                   ┬º\x01\x01\n\x0b┬º();
  279.                   ┬º\x01\x01\n\b┬º = ┬º\x01\x01\x0b\x07┬º;
  280.                }
  281.             }
  282.          }
  283.       }
  284.       
  285.       public function DeactivateFire(param1:*) : *
  286.       {
  287.          if(param1 == 1)
  288.          {
  289.             ┬º\x01\x01\n\x10┬º.x = FIREINITX;
  290.             ┬º\x01\x01\n\x10┬º.gotoAndStop(1);
  291.          }
  292.          else if(param1 == 2)
  293.          {
  294.             ┬º\x01\x01\x0b\x01┬º.x = FIREINITX;
  295.             ┬º\x01\x01\x0b\x01┬º.gotoAndStop(1);
  296.          }
  297.          else if(param1 == 3)
  298.          {
  299.             ┬º\x01\x01\x0b\x05┬º.x = FIREINITX;
  300.             ┬º\x01\x01\x0b\x05┬º.gotoAndStop(1);
  301.          }
  302.          else if(param1 == 4)
  303.          {
  304.             ┬º\x01\x01\x0b\x02┬º.x = FIREINITX;
  305.             ┬º\x01\x01\x0b\x02┬º.gotoAndStop(1);
  306.          }
  307.       }
  308.       
  309.       private function ┬º\x01\x01\n\n┬º() : int
  310.       {
  311.          var _loc1_:int = 0;
  312.          _loc1_ = 0;
  313.          if(theKnight.x > DOC_QUARTI && theKnight.x <= DOC_MIDH)
  314.          {
  315.             if(_loc1_ < 5)
  316.             {
  317.                ┬º\x01\x01\n\x02┬º(2);
  318.             }
  319.             else if(_loc1_ < 7)
  320.             {
  321.                ┬º\x01\x01\n\x02┬º(3);
  322.             }
  323.             else if(_loc1_ < 9)
  324.             {
  325.                ┬º\x01\x01\n\x02┬º(4);
  326.             }
  327.             else
  328.             {
  329.                ┬º\x01\x01\n\x02┬º(1);
  330.             }
  331.             return DRAGONATTACKFIRE;
  332.          }
  333.          if(theKnight.x > DOC_MIDH && theKnight.x <= DOC_QUARTII)
  334.          {
  335.             return DRAGONATTACKBLAST;
  336.          }
  337.          if(theKnight.x > DOC_QUARTII)
  338.          {
  339.             _loc1_ = Math.random() * 10;
  340.             if(_loc1_ < 5)
  341.             {
  342.                ┬º\x01\x01\n\x02┬º(2);
  343.             }
  344.             else if(_loc1_ < 7)
  345.             {
  346.                ┬º\x01\x01\n\x02┬º(3);
  347.             }
  348.             else if(_loc1_ < 9)
  349.             {
  350.                ┬º\x01\x01\n\x02┬º(4);
  351.             }
  352.             else
  353.             {
  354.                ┬º\x01\x01\n\x02┬º(1);
  355.             }
  356.             return DRAGONATTACKUPPER;
  357.          }
  358.          return 0;
  359.       }
  360.       
  361.       public function GetCharType() : String
  362.       {
  363.          return "dragon";
  364.       }
  365.       
  366.       private function ┬º\x01\x01\n\x0b┬º() : Boolean
  367.       {
  368.          if(this.hitTestObject(theKnight.hitdetector))
  369.          {
  370.             if(┬º\x01\x01\x0b\x07┬º == DRAGONATTACKUPPER)
  371.             {
  372.                theKnight.DragonAttack(HEALTHDAMAGE * 0.5,ARMORDAMAGE * 0.5);
  373.             }
  374.             else
  375.             {
  376.                theKnight.DragonAttack(HEALTHDAMAGE,ARMORDAMAGE);
  377.             }
  378.             return true;
  379.          }
  380.          return false;
  381.       }
  382.       
  383.       public function Init(param1:*, param2:*, param3:*) : *
  384.       {
  385.          ┬º\x01\x01\x02\t┬º = param1;
  386.          ┬º\x01\x01\x06\r┬º = param2;
  387.          theKnight = param3.theKnight;
  388.          ┬º\x01\x01\n\r┬º = this.x;
  389.          ┬º\x01\x01\n\x0e┬º = this.y;
  390.          ┬º\x01\x01\n\x0f┬º();
  391.          ┬º\x01\x01\n\x03┬º = DRAGONINITDELAY;
  392.          ┬º\x01\x01\x0b\x06┬º = Math.round((Math.random() * ┬º\x01\x01\n\x03┬º + ┬º\x01\x01\n\x03┬º) / 42);
  393.          ┬º\x01\x01\n\x06┬º(DRAGONHIDE);
  394.          ┬º\x01\x01\x02\t┬º.addEventListener(Event.ENTER_FRAME,┬º\x01\x01\n\t┬º,false,0,true);
  395.       }
  396.       
  397.       private function ┬º\x01\x01\n\f┬º() : *
  398.       {
  399.          if(┬º\x01\x01\n\x10┬º == null)
  400.          {
  401.             ┬º\x01\x01\x06\r┬º.removeChild(┬º\x01\x01\n\x10┬º);
  402.             ┬º\x01\x01\n\x10┬º = null;
  403.          }
  404.          if(┬º\x01\x01\x0b\x01┬º == null)
  405.          {
  406.             ┬º\x01\x01\x06\r┬º.removeChild(┬º\x01\x01\x0b\x01┬º);
  407.             ┬º\x01\x01\x0b\x01┬º = null;
  408.          }
  409.          if(┬º\x01\x01\x0b\x05┬º == null)
  410.          {
  411.             ┬º\x01\x01\x06\r┬º.removeChild(┬º\x01\x01\x0b\x05┬º);
  412.             ┬º\x01\x01\x0b\x05┬º = null;
  413.          }
  414.          if(┬º\x01\x01\x0b\x02┬º == null)
  415.          {
  416.             ┬º\x01\x01\x06\r┬º.removeChild(┬º\x01\x01\x0b\x02┬º);
  417.             ┬º\x01\x01\x0b\x02┬º = null;
  418.          }
  419.       }
  420.       
  421.       public function GetHealthDamage() : int
  422.       {
  423.          if(this.currentLabel == "biting")
  424.          {
  425.             return HEALTHDAMAGE;
  426.          }
  427.          if(this.currentLabel == "blasting")
  428.          {
  429.             return HEALTHDAMAGE * 0.75;
  430.          }
  431.          return 0;
  432.       }
  433.       
  434.       private function ┬º\x01\x01\n\x0f┬º() : *
  435.       {
  436.          if(┬º\x01\x01\n\x10┬º == null)
  437.          {
  438.             ┬º\x01\x01\n\x10┬º = new fireball();
  439.             ┬º\x01\x01\n\x10┬º.x = FIREINITX;
  440.             ┬º\x01\x01\n\x10┬º.y = FIREINITY;
  441.             ┬º\x01\x01\n\x10┬º.Init(┬º\x01\x01\x02\t┬º,┬º\x01\x01\x06\r┬º,this,1);
  442.             ┬º\x01\x01\x06\r┬º.addChild(┬º\x01\x01\n\x10┬º);
  443.             DeactivateFire(1);
  444.          }
  445.          if(┬º\x01\x01\x0b\x01┬º == null)
  446.          {
  447.             ┬º\x01\x01\x0b\x01┬º = new fireball();
  448.             ┬º\x01\x01\x0b\x01┬º.x = FIREINITX;
  449.             ┬º\x01\x01\x0b\x01┬º.y = FIREINITY;
  450.             ┬º\x01\x01\x0b\x01┬º.Init(┬º\x01\x01\x02\t┬º,┬º\x01\x01\x06\r┬º,this,2);
  451.             ┬º\x01\x01\x06\r┬º.addChild(┬º\x01\x01\x0b\x01┬º);
  452.             DeactivateFire(2);
  453.          }
  454.          if(┬º\x01\x01\x0b\x05┬º == null)
  455.          {
  456.             ┬º\x01\x01\x0b\x05┬º = new fireball();
  457.             ┬º\x01\x01\x0b\x05┬º.x = FIREINITX;
  458.             ┬º\x01\x01\x0b\x05┬º.y = FIREINITY;
  459.             ┬º\x01\x01\x0b\x05┬º.Init(┬º\x01\x01\x02\t┬º,┬º\x01\x01\x06\r┬º,this,3);
  460.             ┬º\x01\x01\x06\r┬º.addChild(┬º\x01\x01\x0b\x05┬º);
  461.             DeactivateFire(3);
  462.          }
  463.          if(┬º\x01\x01\x0b\x02┬º == null)
  464.          {
  465.             ┬º\x01\x01\x0b\x02┬º = new fireball();
  466.             ┬º\x01\x01\x0b\x02┬º.x = FIREINITX;
  467.             ┬º\x01\x01\x0b\x02┬º.y = FIREINITY;
  468.             ┬º\x01\x01\x0b\x02┬º.Init(┬º\x01\x01\x02\t┬º,┬º\x01\x01\x06\r┬º,this,4);
  469.             ┬º\x01\x01\x06\r┬º.addChild(┬º\x01\x01\x0b\x02┬º);
  470.             DeactivateFire(4);
  471.          }
  472.       }
  473.       
  474.       public function Destroy() : *
  475.       {
  476.          ┬º\x01\x01\n\f┬º();
  477.          ┬º\x01\x01\x02\t┬º.removeEventListener(Event.ENTER_FRAME,┬º\x01\x01\n\t┬º);
  478.       }
  479.       
  480.       private function ┬º\x01\x01\x0b\b┬º(param1:int) : *
  481.       {
  482.          if(┬º\x01\x01\x0b\x03┬º >= param1)
  483.          {
  484.             if(param1 == 1)
  485.             {
  486.                ┬º\x01\x01\n\x10┬º.gotoAndPlay(1);
  487.                ┬º\x01\x01\n\x10┬º.Activate();
  488.             }
  489.             else if(param1 == 2)
  490.             {
  491.                ┬º\x01\x01\x0b\x01┬º.gotoAndPlay(1);
  492.                ┬º\x01\x01\x0b\x01┬º.Activate();
  493.             }
  494.             else if(param1 == 3)
  495.             {
  496.                ┬º\x01\x01\x0b\x05┬º.gotoAndPlay(1);
  497.                ┬º\x01\x01\x0b\x05┬º.Activate();
  498.             }
  499.             else if(param1 == 4)
  500.             {
  501.                ┬º\x01\x01\x0b\x02┬º.gotoAndPlay(1);
  502.                ┬º\x01\x01\x0b\x02┬º.Activate();
  503.             }
  504.          }
  505.       }
  506.    }
  507. }
  508.